<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>beginPath使用</title>
    <style>
        canvas{
            border: 1px solid #333;
        }
    </style>
</head>
<body>
    <canvas id="canvas" width="600" height="600"></canvas>
    <script>
        const canvas = document.getElementById('canvas');
        const ctx = canvas.getContext('2d');

        ctx.moveTo(100,100);
        ctx.lineWidth = 5;
        ctx.strokeStyle = 'red';
        ctx.lineTo(200,200);
        ctx.stroke();

        ctx.beginPath();   
        ctx.moveTo(200,200);
        ctx.strokeStyle = 'blue';
        ctx.lineWidth = 5;
        ctx.lineTo(300,100);
        ctx.stroke();
    </script>
</body>
</html>